package data_management;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.util.Vector;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;

import UI.InventoryInterface;
import UI.SaleInterface;
import UI.SignInInterface;



public class Main extends JFrame implements WindowListener {

	public static final int DEFAULT_WIDTH = 700;
	public static final int DEFAULT_HEIGHT = 550;
	
	public static Main main;

	public JTabbedPane tabPane;

	public Main() {
		super("New Bird");
		
		addWindowListener(this);
		
		Image newbird = null;
		try {
			newbird = ImageIO.read(getClass().getResourceAsStream("/nbthumbnail.png"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		setIconImage(newbird);
		main = this;
		
		InventoryInterface.getInstance().initialize();
		SaleInterface.getInstance().initialize();
		PermissionManager.getInstance().initialize();
		
		SignInInterface.getInstance().initialize();
		add(SignInInterface.getInstance());

		
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		pack();
		setMinimumSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT));
		setVisible(true);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		InvDBManager db = InvDBManager.getInstance();
		db.initializeDatabase();
		
		new Main();
	}

	public static Main getInstance() {
		return main;
	}
	
	

	@Override
	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowClosing(WindowEvent e) {

		InvDBManager.getInstance().cleanUp();
	}

	@Override
	public void windowDeactivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowDeiconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowIconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowOpened(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}
}
